export default {
  data() {
    return {
      timer: null,
    };
  },
  methods: {
    scroll(element, aim) {
      let len = aim - element.scrollTop;
      let step = Math.round(len / 30);
      if (this.timer) {
        clearInterval(this.timer);
      }
      this.timer = setInterval(() => {
        element.scrollTop += step;
        if (
          aim - element.scrollTop < step + 80 ||
          element.scrollHeight - element.clientHeight < element.scrollTop + step
        ) {
          clearInterval(this.timer);
        }
      }, 10);
    },
  },
};
